import request from '@/utils/request.js';
import { userTokenStore } from '@/stores/token.js';


//线路列表查询
export const routeListService = (params)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        params:params,
        headers:{
            'token':token
        }
    };
    return request.get('/routes',requestConfig);
}

//线路添加
export const routeAddService = (routeData)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        headers:{
            'token':token
        }
    };
    return request.post('/routes',routeData,requestConfig)
}

//修改线路
export const routeUpdateService = (routeData)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        headers:{
            'token':token
        }
    };
    return request.put('/routes',routeData,requestConfig)
}

//删除线路
export const routeDeleteService = (routeId)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        headers:{
            'token':token
        }
    };
    return request.delete('/routes/'+ routeId,requestConfig)
}

//站点列表查询
export const stationListService = (params)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        params:params,
        headers:{
            'token':token
        }
    };
    return request.get('/stations',requestConfig)
}

//站点添加
export const stationAddService = (stationData)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        headers:{
            'token':token
        }
    };
    return request.post('/stations',stationData,requestConfig)
}

//修改站点
export const stationUpdateService = (stationData)=>{
    return request.put('/stations',stationData)
}

//删除线路
export const stationDeleteService = (stationId)=>{
    const tokenStore = userTokenStore();
    const token = tokenStore.token;
    const requestConfig = {
        headers:{
            'token':token
        }
    };
    return request.delete('/stations/'+ stationId,requestConfig)
}